package com.wanxi.web.controller;

import com.wanxi.coupon.api.query.*;
import com.wanxi.coupon.api.result.CommonResult;
import com.wanxi.coupon.api.vo.*;
import com.wanxi.web.service.coupon.CouponWebService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;


/**
 * ClassName: CouponController
 * Description: 优惠券
 * date: 2022/1/13 9:12
 *
 * @author lxl
 * @version 1.0
 * @since JDK 1.8
 */
@RestController
@RequestMapping("admin/coupon")
@Api(tags = "管理员优惠券接口")
public class AdminCouponController {

    @Resource
    private CouponWebService couponWebService;


    /**
     * @Author lxl
     * @Description // 管理员根据给定参数查询对应的优惠券信息接口
     **/
    @ApiOperation("平台查询优惠券的信息")
    @GetMapping("findAll")
    public CommonResult adminFindAll( CouponAdminQuery couponAdminQuery){
        return couponWebService.adminFindAll(couponAdminQuery);
    }

    /**
     * @Author lxl
     * @Description //管理员根据给定参数查询对应的优惠券统计信息接口
     **/
    @ApiOperation("平台查询优惠券的统计信息")
    @GetMapping("findStatistic")
    public CommonResult adminFindStatistic (CouponAdminStatisticQuery couponAdminStatisticQuery){
        return couponWebService.adminFindStatistic(couponAdminStatisticQuery);
    }

    /**
     * @Author lxl
     * @Description //管理员通过id查询优惠券信息接口
     **/
    @ApiOperation("平台通过id查询优惠券")
    @ApiImplicitParam(name = "id",value = "要查询的优惠券id",dataType = "Integer")
    @GetMapping("findById")
    public CommonResult adminFindById( Long id){
        return couponWebService.adminFindById(id);
    }

    /**
     * @Author lxl
     * @Description //管理员添加优惠券信息接口
     **/
    @ApiOperation("平台添加优惠券数据接口")
    @PostMapping("add")
    public CommonResult adminAdd( CouponAdminTDO couponAdminTDO){
        return couponWebService.adminAdd(couponAdminTDO);
    }

    /**
     * @Author lxl
     * @Description 管理员删除优惠券信息接口
     **/
    @ApiImplicitParam(name = "id",value = "要删除的优惠券的id，",dataType = "Integer")
    @PutMapping("delete")
    public CommonResult adminDelete(Integer id){
        return couponWebService.adminDelete(id);
    }

    /**
     * @Author lxl
     * @Description  管理员查询优惠券条数接口
     **/
    @ApiOperation("查询优惠券的条数")
    @GetMapping("getCount")
    public CommonResult adminGetCount(CouponAdminQuery couponAdminQuery){
        return couponWebService.adminGetCount(couponAdminQuery);
    }

}
